package com.yeqian.user.controller;


import com.github.pagehelper.PageInfo;
import com.yeqian.entity.ResultJson;
import com.yeqian.user.entity.RoleInfo;
import com.yeqian.user.service.RoleInfoService;
import com.yeqian.vo.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 角色管理控制器
 */
@Slf4j
@RestController
@RequestMapping(Urls.RoleInfo.ROLE_INFO)
public class RoleInfoController {

    @Resource
    private RoleInfoService roleInfoService;

    /**
     * 查看角色列表
     * @param pageVO
     * @return
     */
    @PreAuthorize("hasRole('bmy')")
    @PostMapping(Urls.RoleInfo.LIST_ROLEINFO)
    public ResultJson listRoleInfo(@RequestBody PageVO pageVO) {
        PageInfo<RoleInfo> list = roleInfoService.listRoleInfo(pageVO);
        return ResultJson.Success("查看角色列表成功", list);
    }

}
